<?php
/* Squawk Content Management System
"Crane"
Written by Max Morgan <max@cridiron.com>

Licensed under GPLv3 (See LICENSE.txt for details)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */

// Index file
// Ties together everything

include('includes.php');		// Global config file

// Step 1: Check for database connectivity
if (!$mysqlcon)
{
	$sqlconfail = "Cannot connect to database: " . mysql_error();	// Print SQL error for debugging
	echo "
	<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
	<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
	<head>
	<meta http-equiv='Content-type' content='text/html;charset=UTF-8' /> 
	<title>$SiteName - Error</title>
	</head>
	<body>
	<p><a href='$BaseURL'><img src='$cclogo' alt='$SiteName' style='border-style: none' /></a></p>
	<p><em>$SiteMotto</em></p>
	<hr />

	<!-- Begin error report -->
	<p>Error:
	<br />$sqlconfail</p>
	<p>Please note, this is not an error with your browser, but rather on our end
	of things.</p>
	<p>Contact $admincta for assistance.</p>
	<!-- End error report -->

	<!-- Begin footer -->
	<hr />	
	<p>$ccfooter</p>
	<p><a href='http://validator.w3.org/check?uri=referer'>
	<img src='http://www.w3.org/Icons/valid-xhtml10' alt='Valid
	XHTML 1.0 Strict' height='31' width='88' style='border-style: none' /></a></p>
	<!-- Build version footer, remove it if you like -->
	<p><em>$VFooter</em></p>
	<!-- End footer -->
	</body>
	</html>";
}

// Step 2: Get posts, show results
else
{
	// Build XHTML header
	echo "
	<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
	<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
	<head>
	<meta http-equiv='Content-type' content='text/html;charset=UTF-8' /> 
	<title>$SiteName</title>
	</head>
	<body>
	<p><a href='$BaseURL'><img src='$cclogo' alt='$SiteName' style='border-style: none' /></a></p>
	<p><em>$SiteMotto</em></p>
	<hr />";

	// Call post grabbing function
	GetPosts();

	// Build XHTML footer
	echo"
	<!-- Begin footer -->
	<hr />	
	<p>$ccfooter</p>
	<p><a href='http://validator.w3.org/check?uri=referer'>
	<img src='http://www.w3.org/Icons/valid-xhtml10' alt='Valid
	XHTML 1.0 Strict' height='31' width='88' style='border-style: none' /></a></p>
	<!-- Build version footer, remove it if you like -->
	<p>$VFooter</p>
	<!-- End footer -->
	</body>
	</html>";
}
// Close database connection
mysql_close($mysqlcon);

?>
